<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <title>Skapa lunchmeny</title>
    </h:head>
    <h:body>
        <ui:composition template="../../admin/adminTemplate.xhtml">
            
            <ui:define name="title">
                Admin Schema
            </ui:define>
            
            <ui:define name="page">
                <h:outputStylesheet library="css" name="schemaStyle.css"  />
                
                <h1>Skapa lunchmenyn</h1>
                <p style="font-size: 25px;">Klicka på en ruta för att fylla i menyn för den dagen.</p>
                #{lunchMenu.readLunches()}
                <table class="form">
                    <tr>
                        <td class="right">
                            <h:form>
                                <h:commandButton value="&lt;&lt;" action="#{lunchMenu.prevWeek()}"/>
                            </h:form>
                        </td>
                        <td class="center">
                            <h:outputText value="Vecka: #{lunchMenu.week}"/>
                        </td>
                        <td class="left">
                            <h:form>
                                <h:commandButton value="&gt;&gt;" action="#{lunchMenu.nextWeek()}"/>
                            </h:form>
                        </td>
                    </tr>
                    <tr>
                        <td class="center" colspan="3">
                            <table>
                                <tr>
                                    <td></td>
                                    
                                    <td class="menuCol">
                                        #{lunchMenu.loadDayLunches(0)}
                                        <h:form>
                                            <h:commandLink styleClass="shift" action="#{lunchMenu.newMenu(lunchMenu.weekDates.get(0))}">
                                                <h4 class="menuTitle">Måndag</h4>
                                                <br/>
                                                #{lunchMenu.weekDates.get(0)} <br/><hr class="menuSpacer"/>
                                                <ui:repeat value="#{lunchMenu.lunches}" var="o" varStatus="status">
                                                    <h:outputText value="#{o.lunchName}"/> <br/>
                                                </ui:repeat>
                                            </h:commandLink> 
                                        </h:form>
                                    </td>
                                    
                                    <td class="menuCol">
                                        #{lunchMenu.loadDayLunches(1)}
                                        <h:form>
                                            <h:commandLink styleClass="shift" action="#{lunchMenu.newMenu(lunchMenu.weekDates.get(1))}">
                                                <h4 class="menuTitle">Tisdag</h4>
                                                <br/>
                                                #{lunchMenu.weekDates.get(1)} <br/><hr class="menuSpacer"/>
                                                <ui:repeat value="#{lunchMenu.lunches}" var="o" varStatus="status">
                                                    <h:outputText value="#{o.lunchName}"/> <br/>
                                                </ui:repeat>
                                            </h:commandLink> 
                                        </h:form>
                                    </td>
                                    
                                    <td class="menuCol">
                                        #{lunchMenu.loadDayLunches(2)}
                                        <h:form>
                                            <h:commandLink styleClass="shift" action="#{lunchMenu.newMenu(lunchMenu.weekDates.get(2))}">
                                                <h4 class="menuTitle">Onsdag</h4>
                                                <br/>
                                                #{lunchMenu.weekDates.get(2)} <br/><hr class="menuSpacer"/>
                                                <ui:repeat value="#{lunchMenu.lunches}" var="o" varStatus="status">
                                                    <h:outputText value="#{o.lunchName}"/> <br/>
                                                </ui:repeat>
                                            </h:commandLink> 
                                        </h:form>
                                    </td>
                                    
                                    <td class="menuCol">
                                        #{lunchMenu.loadDayLunches(3)}
                                        <h:form>
                                            <h:commandLink styleClass="shift" action="#{lunchMenu.newMenu(lunchMenu.weekDates.get(3))}">
                                                <h4 class="menuTitle">Torsdag</h4>
                                                <br/>
                                                #{lunchMenu.weekDates.get(3)} <br/><hr class="menuSpacer"/>
                                                <ui:repeat value="#{lunchMenu.lunches}" var="o" varStatus="status">
                                                    <h:outputText value="#{o.lunchName}"/> <br/>
                                                </ui:repeat>
                                            </h:commandLink> 
                                        </h:form>
                                    </td>
                                    
                                    <td class="menuCol">
                                        #{lunchMenu.loadDayLunches(4)}
                                        <h:form>
                                            <h:commandLink styleClass="shift" action="#{lunchMenu.newMenu(lunchMenu.weekDates.get(4))}">
                                                <h4 class="menuTitle">Fredag</h4>
                                                <br/>
                                                #{lunchMenu.weekDates.get(4)} <br/><hr class="menuSpacer"/>
                                                <ui:repeat value="#{lunchMenu.lunches}" var="o" varStatus="status">
                                                    <h:outputText value="#{o.lunchName}"/> <br/>
                                                </ui:repeat>
                                            </h:commandLink> 
                                        </h:form>
                                    </td>
                                    
                                    <td class="menuCol">
                                        #{lunchMenu.loadDayLunches(5)}
                                        <h:form>
                                            <h:commandLink styleClass="shift" action="#{lunchMenu.newMenu(lunchMenu.weekDates.get(5))}">
                                                <h4 class="menuTitle">Lördag</h4>
                                                <br/>
                                                #{lunchMenu.weekDates.get(5)} <br/><hr class="menuSpacer"/>
                                                <ui:repeat value="#{lunchMenu.lunches}" var="o" varStatus="status">
                                                    <h:outputText value="#{o.lunchName}"/> <br/>
                                                </ui:repeat>
                                            </h:commandLink> 
                                        </h:form>
                                    </td>
                                    
                                    <td class="menuCol">
                                        #{lunchMenu.loadDayLunches(6)}
                                        <h:form>
                                            <h:commandLink styleClass="shift" action="#{lunchMenu.newMenu(lunchMenu.weekDates.get(6))}">
                                                <h4 class="menuTitle">Söndag</h4>
                                                <br/>
                                                #{lunchMenu.weekDates.get(6)} <br/><hr class="menuSpacer"/>
                                                <ui:repeat value="#{lunchMenu.lunches}" var="o" varStatus="status">
                                                    <h:outputText value="#{o.lunchName}"/> <br/>
                                                </ui:repeat>
                                            </h:commandLink> 
                                        </h:form>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <br/>
                   
                <h:panelGroup layout="block" rendered="#{lunchMenu.menuEdit != false}">
                    #{lunchMenu.lunchNames.clear()}
                    <h:form>
                        <h:selectManyListbox value="#{lunchMenu.lunchNames}">
                            <f:selectItems value="#{lunchMenu.saveLunches}" var="f"
                                           itemLabel="#{f.lunchName}" itemValue="#{f.lunchName}"/>
                        </h:selectManyListbox>
                        <br/>
                        <h5>Valt datum: #{lunchMenu.menuDate}</h5>                       
                        <h:commandButton value="Spara" action="#{lunchMenu.saveEdit(lunchMenu.menuDate)}"/> &nbsp;
                        <h:commandButton value="Ta bort menyn" action="#{lunchMenu.removeMenu(lunchMenu.menuDate)}"/> &nbsp;
                        <h:commandButton value="Stäng" action="#{lunchMenu.closeEdit()}"/>
                    </h:form>
                    <br/>
                    <div>
                        Välj en eller flera rätter att lägga till i menyn för dagen som är vald.
                    </div>
                </h:panelGroup>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

